package com.zhoug.zmuidemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.zhoug.zmuidemo.R;

public class RoundViewActivity extends AppCompatActivity {
    private static final String TAG = ">>>RoundViewActivity";
    private ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_round_view);
        findViews();

        Drawable roundbtn = getResources().getDrawable(R.drawable.roundbtn);
        ColorStateList round_btn_font = getResources().getColorStateList(R.color.round_btn_font);
        ColorStateList colorAccent = getResources().getColorStateList(R.color.colorAccent);

        Log.d(TAG, "onCreate: roundbtn="+roundbtn);
        Log.d(TAG, "onCreate: round_btn_font="+round_btn_font);
        Log.d(TAG, "onCreate: colorAccent="+colorAccent);

        printColor(round_btn_font);

        printColor(colorAccent);
    }


    private void printColor(ColorStateList colorStateList){
        Log.d(TAG, "printColor: >>>>>>>>>>>>>>"+colorStateList);
        // <item android:color="#ffff00" android:state_pressed="true">
        int[] pressed=new int[]{android.R.attr.state_pressed,android.R.attr.enabled};
        int[] pressedfalse=new int[]{android.R.attr.state_pressed};
        int[] normal=new int[]{};
        int colorForpressed = colorStateList.getColorForState(pressed, 1);
        int colorForpressedfalse = colorStateList.getColorForState(pressedfalse, 1);
        int colorFornormal = colorStateList.getColorForState(normal, 1);
        Log.d(TAG, "printColor: colorForpressed="+Integer.toHexString(colorForpressed));
        Log.d(TAG, "printColor: colorForpressedfalse="+Integer.toHexString(colorForpressedfalse));
        Log.d(TAG, "printColor: colorFornormal="+Integer.toHexString(colorFornormal));
    }

    private void findViews() {
        mImageView = findViewById(R.id.imageView);
    }
}